New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

@turf/points-within-polygon

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@turf/points-within-polygon

turf points-within-polygon module

5.1.5
Version published
Weekly downloads
977K
-12.88%
Maintainers
4
Weekly downloads
 
Created

What is @turf/points-within-polygon?

@turf/points-within-polygon is a module from the Turf.js library that allows you to determine which points from a set of points fall within a given polygon. This is particularly useful for geospatial analysis, such as finding all locations within a specific area.

What are @turf/points-within-polygon's main functionalities?

Filter Points Within a Polygon

This feature allows you to filter a collection of points to find those that fall within a specified polygon. The code sample demonstrates creating a set of points and a polygon, then using the `pointsWithinPolygon` function to find which points are inside the polygon.

const turf = require('@turf/turf');

const points = turf.featureCollection([
  turf.point([0, 0]),
  turf.point([1, 1]),
  turf.point([2, 2]),
  turf.point([3, 3])
]);

const polygon = turf.polygon([[
  [0, 0], [0, 2], [2, 2], [2, 0], [0, 0]
]]);

const pointsWithin = turf.pointsWithinPolygon(points, polygon);
console.log(pointsWithin);

Other packages similar to @turf/points-within-polygon

FAQs

Package last updated on 10 Dec 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts